#pragma once

#include "MBOctreeNode.h"
#include "MBVec3.h"

class MBTriangle;

/**
  * Octree partitioning the 3D space and containing a set of MBTriangle objects
  */
class MBOctree
{
public:
	MBOctree( void );
	~MBOctree( void );

	MBuint GetNumberOfTriangles( void ) const;
	void Init(
		const MBVec3 &centerPosition,
		const MBVec3 &sideLengths,
		const MBuint &maxLevels,
		const std::vector<MBTriangle*> *triangles,
		const std::vector<double*> *vertexCoordinates );

	bool IsOtherTriangleIntersectingSightFrustum(
		const MBuint *triangleVertexIndices,
		const MBVec3 &cameraPosition ) const;

	bool IsOtherTriangleIntersectingSightTriangle(
		const MBuint *edgeVertexIndices,
		const MBVec3 &cameraPosition ) const;

private:
	/** Pointer to the root node object of the Octree */
	MBOctreeNode *mRoot;
	/** Const pointer to the vector with all the pointers to the MBTriangle objects the octree contains */
	const std::vector<MBTriangle*> *mTriangles;
	/** Const pointer to a vector with all the 3D vertex coordinates of the model */
	const std::vector<double*> *mVertexCoordinates;
};